#include "apfsds_config.h"

static TLS_INITIAL apdsfuture_t apdsfuture_tls[LOCK_MAXFUTURES]; 
static TLS_INITIAL hword_t apdsfuture_cnt; 
static TLS_INITIAL slist_t *apdsfuture_head;
SAI apdsfuture_t *apfsdsfuture_get_tls(){
	if (!apdsfuture_head){
		ASSERT(apdsfuture_cnt < LOCK_MAXFUTURES);
		return &apdsfuture_tls[apdsfuture_cnt++];
	}
	slist_t *ret = apdsfuture_head;
	apdsfuture_head = ret->next;
	return (apdsfuture_t *)ret;
}
SAI void apfsdsfuture_ret_tls(apdsfuture_t *future){
	slist_t *node = (slist_t *)future;
	node->next = apdsfuture_head;
	apdsfuture_head = node;
}
/* 用ptls alloc和free来解决 */
LOCKS2APDS(pspin, apdspspin, apfsdsfuture_get_tls, apfsdsfuture_ret_tls)


APDS2APFSDS(apdspspin, (OUFUN_OF(alignlknode))->get_lknode,  (OUFUN_OF(alignlknode))->ret_lknode)

/* 初始化 */
// #include <pthreadalt/init.inc.c>
// DEF_SYSINIT(__omega)
// DEF_CFLOWINIT(__omega)
// DEF_CFLOWFIN(__omega)
// DEF_SYSFIN(__omega)

void thread_initializer(){
}